package com.eclipse.e0114_java8.课堂案列;

import java.io.BufferedReader;
import java.io.FileReader;
import java.time.Clock;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.stream.Stream;

public class Test6_时间类 {

	public static void main(String[] args) throws Exception {
		// Date date = new Date();

		Instant start = Instant.now();

		System.out.println(start);
		System.out.println(start.toEpochMilli());

		Instant end = Instant.now();

		Duration duration = Duration.between(start, end);

		System.out.println(duration.toNanos());

		System.out.println(duration.toMillis());

		Clock clock = Clock.systemUTC();

		System.out.println(clock.millis());
		System.out.println(clock.instant());

		LocalDate nowDate = LocalDate.now();

		LocalTime nowTime = LocalTime.now();

		LocalDateTime nowDateTime = LocalDateTime.now();

		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
		System.out.println(nowDate.format(dtf));

		LocalDate nextMouthFirst = nowDate.with(TemporalAdjusters.firstDayOfMonth());

		System.out.println(nextMouthFirst);

		BufferedReader br = new BufferedReader(new FileReader("g:/table1.txt"));

		Stream<String> stream = br.lines();
		
		//exception

		System.out.println(stream.count());
	}

}
